using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace WebShop.Contracts
{
    [Table("Products")]
    public class Product
    {
        public Product()
        {
            this.Order_Details = new HashSet<Order_Detail>();
        }

        [Key]
        [ScaffoldColumn(false)]
        public int ProductID { get; set; }

        [Display(Name = "Product Name")]
        [StringLength(40, MinimumLength = 1, ErrorMessage = "Product Name must be between 1 and 40 characters long.")]
        [Required(ErrorMessage = "Product Name is required.")]
        public string ProductName { get; set; }

        [ScaffoldColumn(false)]
        public int? SupplierID { get; set; }

        [ScaffoldColumn(false)]
        public int? CategoryID { get; set; }

        [Display(Name = "Quantity Per Unit")]
        [StringLength(20, MinimumLength = 0, ErrorMessage = "Quantity must be between 0 and 20 characters long.")]
        public string QuantityPerUnit { get; set; }

        [Display(Name = "Unit Price")]
        [Required(ErrorMessage = "Price must be specified")]
        [Range(0.01, Double.MaxValue, ErrorMessage = "Can't be free")]
        //[DataType(DataType.Currency)]
        public Decimal? UnitPrice { get; set; }

        [Display(Name = "Units In Stock")]
        public Int16? UnitsInStock { get; set; }

        [Display(Name = "Units On Order")]
        public Int16? UnitsOnOrder { get; set; }

        [Display(Name = "Reorder Level")]
        public Int16? ReorderLevel { get; set; }

        [Required]
        public bool Discontinued { get; set; }

        [ConcurrencyCheck]
        [Timestamp]
        public byte[] TimeStamp { get; set; }

        public virtual Category Category { get; set; }
        public virtual ICollection<Order_Detail> Order_Details { get; set; }
        public virtual Supplier Supplier { get; set; }
    }
}
